<template>
  <div class="box-container">
    <el-card style="max-width: 1000px;margin:10px 0;height: 30px;padding-left: 20px">
      回复我的
    </el-card>

    <el-card style="max-width: 1000px;min-height: 200px;padding: 20px">
      <div class="reply-item" v-for="item in replyInfoList" :key="item.id">
        <div class="box">
          <div class="avatar">
            <img :src="item.publisherAvatar" :alt="item.publisherNickname" width="60px">
          </div>
          <div class="reply-info">

            <div class="reply-info-title">
              <span class="reply-nickname" @click="toSpace(item.publisherId)">{{item.publisherNickname}}</span>
              &nbsp;&nbsp;&nbsp;回复了我的评论
            </div>
            <div class="reply-info-content">
              {{item.content}}
            </div>
            <div class="reply-info-footer">
              <div class="datetime">{{item.createTime}}</div>
              <div class="replyIt">
                <el-icon><ChatRound /></el-icon>回复
              </div>
              <div class="like">
                <el-icon><Pointer /></el-icon>点赞
              </div>
            </div>
          </div>
          <div class="source-content" @click="toSourceComment(item.commentId,item.commentTypeId,item.sourceContentId)">
            {{item.targetCommentContent}}
          </div>
        </div>
        <el-divider />
      </div>

    </el-card>
  </div>
</template>
<script setup>
import {onMounted, ref} from "vue";
import {getReplyComments} from "@/api/api.js";
import {useRouter} from "vue-router";

const replyInfoList = ref([
  {
    commentId:1,
    publisherId:1,
    publisherAvatar:"/img/avatar2.webp",
    publisherNickname:"每天都要开心啊",
    content:"我很好。。。。。。。。。。。。。。",
    sourceContentId:1,
    targetCommentId:1,
    targetCommentContent:"你好吗csnadkcjnakjcankl才能打开cdacanjkcnaklcmadslcnalk差点就爱看",
    createTime:'2023年5月16日 16:55',
    commentTypeId:0
  }
])
const replyInfoList1 = ref([
  {
    id:1,
    replierId:1,
    replierAvatar:"/img/avatar2.webp",
    replierNickName:"每天都要开心啊",
    replyContent:"我很好。。。。。。。。。。。。。。",
    sourceContent:"你好吗csnadkcjnakjcankl才能打开cdacanjkcnaklcmadslcnalk差点就爱看",
    replyTime:'2023年5月16日 16:55'
  },{
    id:1,
    replierId:1,
    replierAvatar:"/img/avatar2.webp",
    replierNickName:"每天都要开心啊",
    replyContent:"我很好。。。。。。。。。。。。。。",
    sourceContent:"你好吗csnadkcjnakjcankl才能打开cdacanjkcnaklcmadslcnalk差点就爱看",
    replyTime:'2023年5月16日 16:55'
  },{
    id:1,
    replierId:1,
    replierAvatar:"/img/avatar2.webp",
    replierNickName:"每天都要开心啊",
    replyContent:"我很好。。。。。。。。。。。。。。",
    sourceContent:"你好吗csnadkcjnakjcankl才能打开cdacanjkcnaklcmadslcnalk差点就爱看",
    replyTime:'2023年5月16日 16:55'
  }
])

const queryParam = {
  page:1,
  pageSize:100
}
onMounted(async ()=>{
  const res = await getReplyComments(queryParam)
  console.log(res)
  replyInfoList.value = res.data.records
})

const router = useRouter()
const toSourceComment = (id,typeId,sourceContentId) => {
  console.log(typeof id)
  if(typeId === 1){
    router.push({
      name:"video",
      query:{
        videoId:sourceContentId,
        cId:id,
      }
    })
  }
  if(typeId === 2){
    router.push({
      path:"/dynamic",
      query:{
        dynamicId:sourceContentId,
        cId:id,
      }
    })
  }
  console.log("去原评论:"+id)
}

const toSpace = (id) => {
  router.push({
    name:"home",
    params:{
      id
    }
  })
}
</script>
<style lang="scss" scoped>
:deep(.el-card__body){
  padding: 0;
}
.el-card{
  --el-card-padding:10px
}
.el-card .el-card__body{
  padding: 0;
}
.reply-item .box{
  display: flex;
  box-sizing: border-box;
  width: 100%;
  height: 100px;
  .avatar{
    box-sizing: border-box;
    //padding: 20px;
    width: 50px;
    height: 50px;
    overflow: hidden;
    border-radius: 25px;
    margin-right: 20px;
  }
  .reply-info{
    box-sizing: border-box;
    width: 750px;
    height: 30px;
    //background-color: black;
    .reply-info-title{
      height: 30px;
      font-size: 14px;
      .reply-nickname{
        color: black;
        font-weight: bold;
        cursor: pointer;
      }
    }
    .reply-info-content{
      height: 50px;
      //color: gray;
      color: black;
      font-size: 15px;
    }
    .reply-info-footer{
      color: gray;
      font-size: 12px;
      display: flex;
      .datetime{
        width: 150px;
      }
      .replyIt{
        width: 60px;
      }
      .like{
        width: 60px;
      }
    }
  }
  .source-content{
    box-sizing: border-box;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 50px;
    height: 60px;
    line-height: 20px;
  }
}
.el-divider--horizontal{
  margin:15px 0;
}
</style>

<!--经典修改css变量值的方式控制css-->